Pause.prototype = new Sprite();

function Pause(){
    Sprite.apply(this);
    this.pause = new Sprite();  
    this.pause.graphics.beginFill(white);
    this.pause.graphics.drawRect(0,0,MainContainerWidth,MainContainerHeight);
    this.pause.alpha = 0.7;
    this.pause.visible = true;
    this.pause.mouseChildren=true;
    
    this.continueButton = new Button("Pokračovať");
    this.continueButton.x = MainContainerWidth/2 - this.continueButton.width/2;   
    this.continueButton.y = MainContainerHeight/2 - this.continueButton.height/2;
    
    this.pausni = pausni;
    
    function pausni(e){  
        var owner = e.target.parent;
        if (owner instanceof Level){
            owner.parent.addChild(this);                
            owner.timer.TimerStop();
        }
        else{
            owner.addChild(this);                
            owner.timer.TimerStop();
        }
    }
    
    this.odpausni = odpausni;
    function odpausni(e){        
     var owner = e.target.parent.parent
     if (owner instanceof Stage){
         owner.getChildAt(0).timer.TimerStart();
         owner.removeChildAt(owner.numChildren-1);
     }
     else{
        owner.timer.TimerStart();
        owner.removeChildAt(owner.numChildren-1);
     }
    }
    
    this.continueButton.addEventListener(MouseEvent.CLICK, this.odpausni);
    this.addChild (this.pause);
    this.addChild (this.continueButton);
    
}